<?php
define('ROOT_PATH','../');
define('TEMPLATE_DIR','gmer/');
require_once(ROOT_PATH.'code/bean/config.inc.php');
require_once(ROOT_PATH.'code/class/client/calss.client_ques_class.php');
require_once(ROOT_PATH.'code/class/gmer/class.admin_user.php');
require_once(ROOT_PATH.'code/bean/smarty.config.inc.php');
require_once(ROOT_PATH.'code/bean/db_config.inc.php');
$user=new gmer_user();
$session=check_login('admin/index.php');

$ques_id=$_GET['ques_id'];
$sql="select gm_id from question_info where id=$ques_id";
$res=sql_get_one($sql,__LINE__);
if($user->id!=$res['gm_id']) die('这条已经有别的gm归档过了，你不可以操作他的记录!');

if(isset($_GET['id'])) {
	$id=$_GET['id'];
	$sql="select * from question_class where class_id=$id";
	$res=sql_get_one($sql,__LINE__);
	$class_1=trim($res['title']);
	$parent_id=$res['parent_id'];
	$sql="select title from question_class where class_id=$parent_id";
	$res=sql_get_one($sql,__LINE__);
	$class_0=trim($res['title']);
	
	$sql="update question_info set class_id=$id,edit_class_flag=1 where id=$ques_id";
	sql_run($sql,__LINE__);
	
	//out js
	echo '<script language="javascript" >';
	echo "
	window.opener.document.getElementById('new_class_0').innerHTML='$class_0';
	window.opener.document.getElementById('new_class_1').innerHTML='$class_1';
	window.opener.document.getElementById('edit_class').style.display='';
	window.close();
	";
	
	echo '</script>
	';
	exit();
}
$ques_class=new ques_class();
$ques_class->row=9;
$ques_class->sql='select * from question_class where parent_id=0 order by place';
$ques_class->get_assign_tpl();
$tpl->assign('ques_class',$ques_class);
$tpl->assign('ques_id',$ques_id);
$tpl->display('edit_ques_class.html');
?>